package ex_1_synchronizedMethodLockObject;

public class MyObject {
    synchronized public void methodA(){
        try{
            System.out.println("begin methodA threadName=" + Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("end endTime " + System.currentTimeMillis());
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    synchronized public void methodB(){
        try{
            System.out.println("begin methodB threadName=" + Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("end endTime " + System.currentTimeMillis());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
